<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="http://127.0.0.1:3000/socket.io/socket.io.js"></script>
</head>
<body>

    <from action="http://127.0.0.1:3000">
    <span>
        输入:<input type="text" name="preblem" id="preblem" required>
    </span>
    <span>
        <input type="submit" value="发送" id="send" />

    </span>

    </from>
    <ul id="lists">

    </ul>
</body>
</html>
<script>
    // console.log(io)
    var preblem =document.querySelector("#preblem")
    var send =document.querySelector("#send")
    // var list =document.createElement("list").appendChild("li")
    var socket =io()
    console.log(preblem)
    console.log(socket)
    console.log(send)
    send.onclick=function(ev){
        ev.preventDefault()
        socket.emit("yang",preblem.value)
        // preblem.value = "";
         return false;
    }
    socket.on("yang",function(mes){
        console.log(mes)
        var li =document.createElement("li")
                  li.innerHTML = mes;
         document.querySelector("#lists").appendChild(li)
    })


</script>